// 引用
import Vue from "vue";
import VueRouter from "vue-router";


// 1. 定义 (路由) 组件。
// 可以从其他文件 import 进来

import Home from "@/views/Home.vue"
import User from "@/views/User.vue"
import Mall from "@/views/Mall.vue"
import Main from "@/views/Main.vue"
import PageOne from "@/views/PageOne.vue"
import PageTwo from "@/views/PageTwo.vue"


// 安装
Vue.use(VueRouter)

// 2. 定义路由
const routes = [
    {
        path:'/',
        component:Main,
        redirect:'/home',
        children:[
            { path: '/home', component: Home },//首页
            { path: '/user', component: User },//用户管理页面
            { path: '/mall', component: Mall },//商品管理页面
            { path: '/page1', component: PageOne },//页面1
            { path: '/page2', component: PageTwo },//页面2
        ]
    },
]
// 3. 创建 router 实例，然后传 `routes` 配置
const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})
export default router